home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Clinical Endocrinology
/
Clinical Endocrinology.iso
/
mac
/
00000000
/
Bookmark.dir-old
/
00001_Script_1
next >
Wrap
Text File
|
1995-11-09
|
6KB
|
250 lines
on init
global installedFolderpath, gReadBkMarks, marksList, refList
global bookmarkChoice
set marksList = []
set the keyDownScript = "doAddReturn"
set bookmarkChoice = 1
put fileIO(mNew, "read", installedFolderpath & "Bookmark.DAT") into gReadBkMarks
if not objectp(gReadBkMarks) then
alert "Sorry. Can't find bookmarks data."
else
readBookmarks -- reads the txt file and puts it into a list
makeLinkLists -- splits this list into a reference list and link list
displayRefs -- shows the refList, item by item, in the display field
if count(marksList) > 0 then
hilite line bookmarkChoice of field "Display Field"
else
set bookmarkChoice = 0
end if
end if
end init
-----------------------------------------------------------------------------------
on readBookmarks
global gReadBkMarks, marksList
put gReadBkMarks(mReadFile) into myText
if myText <> "" then
put the number of lines in myText into theLines
repeat with i = 1 to theLines
put line i of myText into myItem
add marksList, myItem
end repeat
end if
gReadBkMarks(mDispose)
end readBookmarks
------------------------------------------------------------------
-- This handler takes marksList made from the txt file
-- and splits it, using two functions, into two lists
--
on makeLinkLists
global marksList, refList, linkList
set refList = []
set linkList = []
repeat with i = 1 to count(marksList)
put getAt(marksList, i) into listString
put stripStart(listString) into refString
add(refList, refString)
put stripEnd(listString) into linkString
add(linkList, linkString)
end repeat
end makeLinkLists
-----------------------------------------------------
-- This is a function!!
-- To use this, use the syntax below
-- put stripStart( <put a string in here> ) into newString
-- where newstring is the stripped word resulting
-- from this function
-- StripEnd uses the same syntax.
on stripStart listString
put the number of chars in listString into theChars
repeat with i = 1 to theChars
if char i of listString = "*" then exit repeat
put char 1 to i of listString into theStart
end repeat
return theStart
end stripStart
-----------------------------------------------------
on stripEnd listString
put the number of chars in listString into theChars
repeat with i = 1 to theChars
if char i of listString = "*" then exit repeat
end repeat
put (i + 1) into newStart
put char newStart to theChars of listString into theEndBit
return theEndBit
end stripEnd
-----------------------------------------------------
on displayRefs
global refList
put "" into theText
put count(refList) into theItems
repeat with i = 1 to theItems
put getAt(refList, i) into theRef
if i = 1 then
put theRef after theText
else
put RETURN & theRef after theText
end if
end repeat
put theText into field "Display Field"
end displayRefs
-----------------------------------------------------
on addBookmark
global refList, linkList, marksList, parentPath, bookmarkChoice
put the text of field "User Field" into newRef
if newRef = "" then
alert "Please name the bookmark first."
else
add refList, newRef
getParentPath
add linkList, parentPath
add marksList, newRef & "*" & parentPath
writeBookMarks
displayRefs
set bookmarkChoice = count(marksList)
hilite line bookmarkChoice of field "Display Field"
end if
end addBookmark
-------------------------------------------------------------
on deleteBookmark
global refList, linkList, marksList, parentPath, bookmarkChoice
if count(marksList) > 0 then
deleteAt marksList, bookmarkChoice
makeLinkLists
writeBookMarks
displayRefs
if count(marksList) > bookmarkChoice then
set bookmarkChoice = count(marksList)
hilite line bookMarkChoice of field "Display Field"
else
set bookmarkChoice = count(marksList)
if bookmarkChoice <> 0 then hilite line bookMarkChoice of field "Display Field"
end if
else
alert "Choose a Bookmark to delete."
end if
end deleteBookmark
-------------------------------------------------------------
on getParentPath
global parentPath
tell the stage
global parentPath
put the pathname & the movieName into parentPath
end tell
end getParentPath
-------------------------------------------------------------
on writeBookMarks
global refList, linkList, marksList, gWriteBkMarks, installedFolderpath
if count(refList) <> count(linkList) then
alert "Missing some data! Try opening Bookmark.DAT" & RETURN &¼
"and erasing all entries! Start from scratch."
end if
put "" into newData
repeat with i = 1 to count(marksList)
if i = 1 then
put getAt(marksList, i) after newData
else
put RETURN & getAt(marksList, i) after newData
end if
end repeat
put fileIO(mNew, "write", installedFolderpath & "Bookmark.DAT") into gWriteBkMarks
if not objectP(gWriteBkMarks) then
alert "Sorry can't find bookmark data."
else
gWriteBkMarks(mWriteString, newData)
gWriteBkMarks(mDispose)
end if
end writeBookMarks
-----------------------------------------------------
on chooseLine
global bookmarkChoice
put the mouseLine into bookmarkChoice
if bookmarkChoice > 0 then
hilite line bookmarkChoice of field "Display Field"
end if
end chooseLine
-----------------------------------------------------
on goToBookMark
global bookmarkChoice, linkList
if bookmarkChoice > count(linkList) then
alert "Please, choose a bookmark."
else if count(linkList) < 1 then
alert "There are no bookmarks. Bookmarks must be added first."
else
put getAt(linkList, bookmarkChoice) into newPath
tell the stage
go movie newPath
end tell
end if
end goToBookMark
------------------------------------------------------
on doAddReturn
if the key = RETURN then
addBookmark
dontPassEvent
end if
end doAddReturn